<template>
  <div class="app-container">
    <git-navigation />
    <el-col :span="22" :offset="1">
      <h3>新建合并请求</h3>
      <el-col :span="12">
        <div class="branch-box mb20">
          <div class="panel-head">来源分支</div>
          <div class="panel-body clearFix">
            <el-select
              v-model="addForm.sourceBranch"
              class="fll"
              style="width:50%;padding-right: 10px;"
            >
              <el-option
                v-for="item in branchesList"
                :key="item.name"
                :label="item.name"
                :value="item.name"
              />
            </el-select>
            <el-select
              v-model="addForm.sourceBranch"
              class="fll"
              placeholder="选择来源分支"
              style="width:50%"
            >
              <el-option
                v-for="item in branchesList"
                :key="item.name"
                :label="item.name"
                :value="item.name"
              />
            </el-select>
          </div>
          <div class="panel-info clearFix">
            <img
              class="fll"
              src="https://tse4-mm.cn.bing.net/th/id/OIP.1e3YVW946dgy5uJH764JXwHaFj?pid=Api&rs=1"
              alt
            >
            <div class="fll">
              <a class="commit-content" href>update</a>
              <div class="commit-detail">付露影 authored 12 分钟前</div>
              <a href class="commit-version">3287e8</a>
              <!-- v-clipboard:copy="commitItem.commit.id" -->
              <i
                v-clipboard:success="onCopy"
                v-clipboard:error="onError"
                class="el-icon-document-copy"
              />
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="12">
        <div class="branch-box mb20">
          <div class="panel-head">目标分支</div>
          <div class="panel-body clearFix">
            <el-select
              v-model="addForm.sourceBranch"
              class="fll"
              style="width:50%;padding-right: 10px;"
            >
              <el-option
                v-for="item in branchesList"
                :key="item.name"
                :label="item.name"
                :value="item.name"
              />
            </el-select>
            <el-select
              v-model="addForm.sourceBranch"
              class="fll"
              placeholder="选择目标分支"
              style="width:50%"
            >
              <el-option
                v-for="item in branchesList"
                :key="item.name"
                :label="item.name"
                :value="item.name"
              />
            </el-select>
          </div>
        </div>
      </el-col>
    </el-col>
    <el-col :span="22" :offset="1">
      <el-button type="success" style="background:#1aaa55">比较分支后继续</el-button>
    </el-col>
  </div>
</template>

<script>
import GitNavigation from './components/GitNavigation';
import { getBranchesList } from '@/utils/apiPath';
export default {
  components: {
    GitNavigation
  },
  filters: {},
  data() {
    return {
      branchesList: [],
      addForm: {
        sourceBranch: '',
        targetBranch: '',
        targetPid: ''
      }
    };
  },
  created() {
    this.getBranchesList();
  },
  methods: {
    getBranchesList() {
      const pid = this.$route.params.pid;
      getBranchesList(pid)
        .then((res) => {
          this.branchesList = res.data;
        })
        .catch(() => {});
    },
    onCopy(e) {
      // 复制成功
      this.$message.success('复制成功');
    },
    onError(e) {
      // 复制失败
      this.$message('复制失败');
    }
  }
};
</script>

<style scoped lang="scss">
@import '../../styles/main.css';
.branch-box {
  margin-right: 20px;
  color: #2e2e2e;
  border: 1px solid #e5e5e5;
  .panel-head {
    padding: 5px 10px;
    font-weight: 600;
    line-height: 25px;
    background-color: #f4f4f4;
    box-sizing: border-box;
    border-bottom: 1px solid #e5e5e5;
  }
  .panel-body {
    padding: 10px 5px;
    box-sizing: border-box;
    border-bottom: 1px solid #e5e5e5;
  }
  .panel-info {
    background-color: #fafafa;
    padding: 10px;
    line-height: 25px;
    color: #2e2e2e;

    img {
      display: inline-block;
      width: 36px;
      height: 36px;
      margin-right: 10px;
      border-radius: 50%;
    }
    .commit-content {
      padding-right: 10px;
      white-space: normal;
      color: #2e2e2e;
    }
    .commit-version {
      margin: 0 16px;
      font-weight: 700;
    }
  }
}
</style>
